home *** CD-ROM | disk | FTP | other *** search
- this.init = function()
- {
- this._x = this.pPos.x;
- this._y = this.pPos.y;
- if(this._parent._name == "grid_mc")
- {
- var _loc2_ = Math.floor(this.pNum / 8);
- var _loc3_ = this.pNum - Math.floor(this.pNum / 8) * 8;
- this._y = -80 - (8 - _loc2_) * 100 - _loc3_ * 15;
- }
- else
- {
- this._y -= 160;
- }
- this.pSpeedX = 0;
- this.pSpeedY = 0;
- this.pLandTest = false;
- this.pCenter = new Object();
- this.pCenter.x = this.pCenter.y = 0;
- this.pAngle = 0;
- this.pAngleStep = 0.6283185307179586;
- this.pDirection = 1;
- this.pDepth = this.getDepth();
- this.pState = 0;
- this.gotoAndStop(this.pColour + 1);
- };
- this.scaleTile = function()
- {
- this.pSpeedY = 0;
- this.pState = 4;
- this.addEnterFrame();
- };
- this.destroyTile = function()
- {
- this.pSpeedX = 0;
- this.pSpeedY = Math.random() * -8;
- this.pState = 5;
- this.addEnterFrame();
- };
- this.startTile = function()
- {
- this._x = this.pPos.x;
- this._y = this.pPos.y;
- this._xscale = 100;
- this._yscale = 100;
- this._alpha = 100;
- var _loc2_ = Math.floor(this.pNum / 8);
- var _loc3_ = this.pNum - Math.floor(this.pNum / 8) * 8;
- this.pSpeedY = 15;
- this.pLandTest = false;
- this.pState = 1;
- this.addEnterFrame();
- this.gotoAndStop(this.pColour + 1);
- this._parent.tileDropDone();
- };
- this.renewTile = function(n, c)
- {
- this.pPos.y = -140 + 40 * Math.floor(n / 8);
- this._x = pPos.x;
- this._y = -250;
- this.pNum = n;
- this.pColour = c;
- this.gotoAndStop(this.pColour + 1);
- this.pSpeedY = 0;
- this.pState = 1;
- this.addEnterFrame();
- };
- this.hideTile = function()
- {
- this._y = this.pPos.y - 160;
- this.pState = 0;
- this.removeEnterFrame();
- };
- this.placeTile = function(tY, tC)
- {
- this._xscale = 100;
- this._yscale = 100;
- this._y = this.pPos.y - tY;
- this.pColour = tC;
- this.gotoAndStop(this.pColour + 1);
- this.pSpeedY = 0;
- this.pState = 1;
- this.addEnterFrame();
- };
- this.dropTile = function(d, tId)
- {
- this.pPos.y += d * 40;
- this.pNum += d * 8;
- this.pSpeedY = 0;
- this.pState = 1;
- this.addEnterFrame();
- };
- this.removeTile = function()
- {
- this.pSpeedY = 0;
- this.pState = 3;
- this.addEnterFrame();
- };
- this.moveTile = function(aX, aY, aDir, aNewNum)
- {
- this.pCenter.x = this.pPos.x - (this.pPos.x - aX) / 2;
- this.pCenter.y = this.pPos.y - (this.pPos.y - aY) / 2;
- this.pDirection = aDir;
- switch(true)
- {
- case this.pPos.x < aX:
- this.pAngle = -3.141592653589793;
- break;
- case this.pPos.x > aX:
- this.pAngle = 0;
- break;
- case this.pPos.y < aY:
- this.pAngle = -1.5707963267948966;
- break;
- case this.pPos.y > aY:
- this.pAngle = 1.5707963267948966;
- }
- this.pPos.x = aX;
- this.pPos.y = aY;
- this.pNum = aNewNum;
- this.pState = 2;
- this.addEnterFrame();
- };
- this.removeEnterFrame = function()
- {
- delete this.onEnterFrame;
- };
- this.addEnterFrame = function()
- {
- this.onEnterFrame = function()
- {
- switch(this.pState)
- {
- case 1:
- this.pSpeedY = Math.min(this.pSpeedY + 2,50);
- this._y += this.pSpeedY;
- if(this._y >= this.pPos.y)
- {
- this._y = this.pPos.y;
- this.pState = 0;
- this._parent.tileDropDone();
- }
- break;
- case 2:
- this.pAngle += this.pAngleStep * this.pDirection;
- this._x = this.pCenter.x + Math.cos(this.pAngle) * 20;
- this._y = this.pCenter.y + Math.sin(this.pAngle) * 20;
- if(Math.abs(this._x - this.pPos.x) < 1)
- {
- if(Math.abs(this._y - this.pPos.y) < 1)
- {
- this._x = this.pPos.x;
- this._y = this.pPos.y;
- this.pState = 0;
- this._parent.tileSwapDone();
- }
- }
- break;
- case 3:
- this.pSpeedY += 10;
- this._xscale -= this.pSpeedY;
- this._yscale -= this.pSpeedY;
- if(this._xscale <= 0)
- {
- this._xscale = 100;
- this._yscale = 100;
- this._y = -180;
- this.pState = 0;
- this._parent.tileClearDone();
- }
- break;
- case 4:
- this.pSpeedY += 5;
- this._xscale -= this.pSpeedY;
- this._yscale -= this.pSpeedY;
- if(this._xscale <= 0)
- {
- this._xscale = 0;
- this._yscale = 0;
- this.pState = 0;
- this._parent.tileScaleDone();
- }
- break;
- case 5:
- this.pSpeedY = Math.min(this.pSpeedY + 2,50);
- this._x += this.pSpeedX;
- this._y += this.pSpeedY;
- if(this._y >= 180)
- {
- this.pState = 0;
- this._parent.tileDestroyDone();
- }
- }
- if(pState == 0)
- {
- this.removeEnterFrame();
- }
- };
- };
- this.init();
- stop();
-